package com.framework.main.sys.indexFream.action;

import java.io.PrintWriter;
import java.util.Map;

import com.framework.base.constant.ActionConstants;
import com.framework.base.struts.BaseAction;
import com.framework.base.util.Struts2Utils;
import com.framework.main.sys.indexFream.service.IndexFreamService;

/**
 * @Title: IndexFreamAction.java
 * @Package com.framework.main.sys.indexFream.action
 * @Description:首页框架处理action.用来获取待办公文，通知公告，文件交流以及统计三项的总数
 * @jdk version 1.6
 * @author www.51wuxia.com
 * @version V1.0
 */
public class IndexFreamAction extends BaseAction {


	public String toIndexBody() throws Exception {	
		
		return ActionConstants.SUCCESS;
	}

	public String toOrganSchedule() throws Exception {
		// 机关人员当天日程
		IndexFreamService indexFreamService = (IndexFreamService) this
				.getBaseService();
		Map<?, ?> organMap = indexFreamService.getOrganSchedule();
		Struts2Utils.getRequest().setAttribute("organMap", organMap);
		return ActionConstants.SUCCESS;
	}
	
	public void toTop() throws Exception {
        PrintWriter out = Struts2Utils.getResponse().getWriter();
        
		IndexFreamService indexFreamService = (IndexFreamService) this.getBaseService();
		// 代办公文总数
		// 通知总数
		int announcementCount = indexFreamService.getAnnouncementCount();
		// 文件交流总数
		int fileCount = indexFreamService.getReceiverNoReaderCount();
		
        String tzgg = "<tzgg>" + announcementCount +"</tzgg>";
        String wjjl = "<wjjl>" + fileCount +"</wjjl>";
        
        Struts2Utils.getResponse().setContentType("text/xml");
        Struts2Utils.getResponse().setHeader("Cache-Control", "no-cache");
        out.write("<?xml version='1.0' encoding='GBK'?>");
        out.write("<response>");
        out.write(tzgg);
        out.write(wjjl);
        out.write("</response>");
        out.close();
	}
}
